<template>
  <div class="businessUnit">
    <Dialog content="累计预算进度=累计收入/累计预算  ;累计预算差距=累计收入-累计预算"></Dialog>
    <!-- :cell-style="cellStyle" -->
    <div class="table">
      <el-table :data="tableData" border :header-cell-style="{
                    background: '#0070C0',
                    color: '#ffffff'
                }" v-loading="tableLoading">
        <el-table-column label="经营单元" prop="areaName" align="center"></el-table-column>
        <el-table-column label="当月环比" align="center">
          <el-table-column label="当月收入" align="center" prop="thisMonthIncome"></el-table-column>
          <el-table-column label="环比" align="center" prop="hbMonInreaseAmt"></el-table-column>
          <el-table-column label="环比增幅" align="center" prop="hbMonthInrease">
            <template slot-scope="scope">
              <div>
                {{ scope.row.hbMonthInrease + "%" }}
              </div>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="累计同比" align="center">
          <el-table-column label="累计收入" align="center" prop="thisYearLjIncome"></el-table-column>
          <el-table-column label="累计同比" align="center" prop="tbYearInreaseAmt"></el-table-column>
          <el-table-column label="累计同比增幅" align="center" prop="tbYearInrease">
            <template slot-scope="scope">
              <div>
                {{ scope.row.tbYearInrease + "%" }}
              </div>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="预算" align="center">
          <el-table-column label="累计预算" align="center" prop="thisYearBudgetLj"></el-table-column>
          <el-table-column label="累计预算进度" align="center" prop="completeBudgetLj">
            <template slot-scope="scope">
              <div v-if="scope.row.completeBudgetLj">
                {{ scope.row.completeBudgetLj + "%" }}
              </div>
              <div v-else>-</div>
            </template>
          </el-table-column>
          <el-table-column label="累计预算差距" align="center" prop="gapOfBudgetLj">
          </el-table-column>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
// import { growthSituation } from "@/api/barCode/index";
import $barCodeApi from "@/api/barCode/index";
import Dialog from './dialog.vue'
export default {
  name: "businessUnit",
  components: {
    Dialog
  },
  props: {
    form: {
      type: Object,
      default: {}
    }
  },
  data () {
    return {
      tableLoading: false,
      tableData: []
    };
  },
  computed: {},
  created () { },
  mounted () { },
  methods: {
    cellStyle ({ row, column, rowIndex, columnIndex }) {
      if (
        row.tbColorSign == "TB_UP_0" &&
        column.label == "累计同比增幅"
      ) {
        return "background: #5A8AC6;padding:0;color:black";
      } else if (
        row.tbColorSign == "TB_UP_1" &&
        column.label == "累计同比增幅"
      ) {
        return "background: #7BA1D2;padding:0;color:black";
      } else if (
        row.tbColorSign == "TB_UP_2" &&
        column.label == "累计同比增幅"
      ) {
        return "background: #D9E4F3;padding:0;color:black";
      } else if (
        row.tbColorSign == "TB_DOWN_0" &&
        column.label == "累计同比增幅"
      ) {
        return "background: #F8696B;padding:0;color:black";
      } else if (
        row.tbColorSign == "TB_DOWN_1" &&
        column.label == "累计同比增幅"
      ) {
        return "background: #F98E95;padding:0;color:black";
      } else if (
        row.tbColorSign == "TB_DOWN_2" &&
        column.label == "累计同比增幅"
      ) {
        return "background: #FABCBE;padding:0;color:black";
      } else if (
        row.hbColorSign == "HB_UP_0" &&
        column.label == "环比增幅"
      ) {
        return "background: #5A8AC6;padding:0;color:black";
      } else if (
        row.hbColorSign == "HB_UP_1" &&
        column.label == "环比增幅"
      ) {
        return "background: #7BA1D2;padding:0;color:black";
      } else if (
        row.hbColorSign == "HB_UP_2" &&
        column.label == "环比增幅"
      ) {
        return "background: #D9E4F3;padding:0;color:black";
      } else if (
        row.hbColorSign == "HB_DOWN_0" &&
        column.label == "环比增幅"
      ) {
        return "background: #F8696B;padding:0;color:black";
      } else if (
        row.hbColorSign == "HB_DOWN_1" &&
        column.label == "环比增幅"
      ) {
        return "background: #F98E95;padding:0;color:black";
      } else if (
        row.hbColorSign == "HB_DOWN_2" &&
        column.label == "环比增幅"
      ) {
        return "background: #FABCBE;padding:0;color:black";
      }
      if (row.displayName == "杭州") {
        return "font-weight:bold;color:black;padding:0;";
      }
      return "color:black;padding:0";
    },
    // 获取码号收入整体趋势
    getList () {
      // import $barCodeApi from "@/api/barCode/index";
      this.tableLoading = true;
      $barCodeApi.growthSituation({ ...this.form }, res => {
        if (res.code == 0) {
          this.tableLoading = false;
          this.tableData = res.content;
        }
      });

      // growthSituation(this.form).then((res) => {
      //   if (res.code == 0) {
      //     this.tableLoading = false
      //     this.tableData = res.content;
      //   }
      // });
    }
  }
};
</script>

<style scoped></style>
